//
//  Adaptive.m
//  自封装头文件
//
//  Created by dllo on 15/10/29.
//  Copyright © 2015年 Wang Jianwei. All rights reserved.
//

#import "Adaptive.h"

@implementation Adaptive
+ (CGFloat)AdaptiveHeightByString:(NSString *)string Width:(CGFloat)width FontSize:(CGFloat)fontSize{
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:fontSize], NSFontAttributeName, nil];
    CGRect rect = [string boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height + 1;;
}
+ (CGFloat)AdaptiveWidthByString:(NSString *)string Height:(CGFloat)height FontSize:(CGFloat)fontSize{
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:fontSize], NSFontAttributeName, nil];
    CGRect rect = [string boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, height) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.width + 1;
}
@end
